#include "ui_graphics_scene.h"
#include "qgraphicsview.h"

/*UiGraphicsScene::UiGraphicsScene(QObject *parent)
    : QGraphicsScene{parent}
{

}*/

UiGraphicsScene::UiGraphicsScene(QImage background_img, QObject *parent)
    :QGraphicsScene(parent), background_image_(background_img)
{
    setSceneRect(background_image_.rect());
}

UiGraphicsScene::~UiGraphicsScene()
{

}

void UiGraphicsScene::DrawDesktopIcon()
{

}

void UiGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect)
{
    if(views().count() == 0)
    {
        return;
    }

    QGraphicsView *pview = views().first();
    QRect contentRect = pview->viewport()->contentsRect();
    QRectF sceneRect = pview->mapToScene(contentRect).boundingRect();
    painter->drawImage(sceneRect, background_image_, sceneRect);
}

void UiGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *evt)
{
    evt->ignore();
}
